#include <iostream>

using namespace std;

const int N = 110;
int n, m;
int w[N * 5], v[N * 5], f[N * 5];
int pos;
int main()
{
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
	{
		int x, y, z; cin >> x >> y >> z;
		int t = 1;
		while (x >= t)
		{
			pos++;
			w[pos] = t * y;
			v[pos] = t * z;
			x -= t;
			t *= 2;
		}
		if (x)
		{
			pos++;
			w[pos] = x * y;
			v[pos] = x * z;
		}
	}
	for (int i = 1; i <= pos; i++)
		for (int j = m; j >= w[i]; j--)
			f[j] = max(f[j], f[j - w[i]] + v[i]);

	cout << f[m] << endl;
	return 0;
}